package com.tater;

import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.concurrent.TimeUnit;

/**
 * @author Administrator
 */
public class ProviderMain {

    public static void main(String[] args) throws InterruptedException {
        AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext(ProviderConfig.class);
        context.start();
        TimeUnit.DAYS.sleep(1);
    }
    @Configuration
    @EnableDubbo(scanBasePackages = "com.tater.service.impl")
    @PropertySource("classpath:/dubbo-provider.properties")
    static class  ProviderConfig{

        /**
         * 将服务注册到zk中
         * @return
         */
        @Bean
        public RegistryConfig registryConfig(){
            RegistryConfig config=new RegistryConfig();
            config.setAddress("zookeeper://localhost:2181");
            return config;
        }

    }
}
